﻿Public Class CINNERLabelState : Inherits CStateBase

    ''' <summary>
    ''' 実行可能かを判断する
    ''' </summary>
    ''' <param name="task"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overrides Function IsEnter(ByVal task As CTaskBase) As Boolean
        Debug.WriteLine("CINNERLabelState.IsEnter")
        If CCommon.isInStr(task.ActionCd, "LABEL-IN") Then
            Return True
        Else
            Return False
        End If
    End Function

    ''' <summary>
    ''' 実行メソッド
    ''' </summary>
    ''' <param name="task"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overrides Function DoExecute(ByVal task As CTaskBase) As CStateBase
        Dim nextState As CStateBase
        Dim pdaTask As CPDATask = DirectCast(task, CPDATask)
        Debug.WriteLine("CINNERLabelState.DoExecute   START")
        'CFileLog.WriteLog("CINNERLabelState.DoExecute START---", CFileLog.LEVEL_NORMAL, CFileLog.EnumLogType.READ)
        Dim checkInfo As CCheck = CCheck.GetIns
        Dim AppManager As CApplicationManager = CApplicationManager.GetInstance

        Dim setData As COrderRecord = pdaTask.WindowManager.SetCurrentInvoice(pdaTask.MazadaLabel)

        Dim uniqueData As CCheck.UniqueCdData = New CCheck.UniqueCdData
        uniqueData.empCd = pdaTask.EmpCd
        uniqueData.uniqueCd = pdaTask.MazadaLabel
        uniqueData.actionDateTime = Now.ToString("yyyy/MM/dd HH:mm:ss")
        uniqueData.isSend = False

        'ユニークコード重複チェック
        If checkInfo.AddUniqueCd_2PK_Data(uniqueData) Then
            pdaTask.Hardware.nextB()
            setData.IsEndFlg = "済"
            pdaTask.ChkMazdaLabel = ""
            pdaTask.ChkDNLabel = ""
            pdaTask.MazadaLabel = ""

            pdaTask.WindowManager.ClearActionLabel()

        Else
            CPersonal.ErrorWindow(pdaTask, EnumWindowMode.ALERT_MODE, _
                             Color.Black, CConst.EnumSound.ALERT_BUZZ, CConst.CNS_MSG_007, Color.White)

            pdaTask.ListCnt -= 1
            '画面にある納品番号を削除
            CPersonal.DelWindowRecord(setData, pdaTask.WindowManager)

            pdaTask.WindowManager.SetRecordDelegate()
            pdaTask.WindowManager.RefreshWindow(1)

            pdaTask.WindowManager.ClearActionLabel()

        End If

        task.ProcessText = ""
        task.ActionCd = "LABELCHECK"
        nextState = GetNextState(task)
        Debug.WriteLine("CINNERLabelState.DoExecute   END")
        'CFileLog.WriteLog("CINNERLabelState.DoExecute END---", CFileLog.LEVEL_NORMAL, CFileLog.EnumLogType.READ)
        Return nextState
    End Function

    ''' <summary>
    ''' 終了メソッド(未使用)
    ''' </summary>
    ''' <param name="task"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overrides Function DoExit(ByVal task As CTaskBase) As Boolean
        Debug.WriteLine("CINNERLabelState.DoExit")
        Return True
    End Function


End Class
